<template>
  <div>
    <div class="item" @click="jumpGoodPage(item.pid,item)">
      <!-- 上半图片部分 -->
      <div class="item_img">
        <img :src="item.smallImg ||item.small_img" alt="">
        <!-- hot 图片 -->
        <div class="hot">
          热卖
        </div>
      </div>
      <!-- 下半文章部分 -->
      <div class="item_text">
        <div class="item_name one_text">
          {{item.name}}
        </div>
        <div class="item_Ename one_text">
          {{item.enname}}
        </div>
        <div>
          <div class="item_price fl">
            ￥{{item.price}}
          </div>
          <div class="fr " v-if="isRemove" @click.stop="remove">
            <van-icon name="delete-o" class="delete-box" />
          </div>
        </div>

      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Pro-item',
  props: {
    item: {
      type: Object,
      default: {}
    },
    isRemove: {
      type: Boolean,
      default: false
    }
  },
  methods: {
    async remove() {
      this.$emit('Remove')
    },
    jumpGoodPage(pid, item) {
      this.$router.push({ name: 'Good', params: { pid } })
      item.time = new Date().toLocaleDateString() + ' ' + new Date().toLocaleTimeString()
      this.$store.commit('addTrackCount', item)
    }
  }
}
</script>

<style lang="less" scoped>
.item {
  // float: left;
  position: relative;
  width: calc(~'100% - 25px');
  // margin-right: 10px;
  padding: 10px;
  background-color: #fff;
  // margin-bottom: 10px;
  border-radius: 8px;
  overflow: hidden;
  &:nth-child(2n) {
    margin-right: 0;
  }
  padding-bottom: 10px;
  .item_img {
    display: flex;
    width: 100%;
    height: 100%;
    position: relative;
    img {
      width: 100%;
      height: 100%;
    }
    .hot {
      position: absolute;
      right: 1px;
      top: 2px;
      width: 35px;
      height: 16px;
      line-height: 16px;
      border-top-right-radius: 5px;
      border-bottom-right-radius: 5px;
      background-color: red;

      color: aliceblue;
      font-size: 10px;
      text-align: center;
    }
  }
}
.item_text {
  .item_name {
    margin-top: 10px;
    color: #444;
    font-size: 15px;
  }
  .item_Ename {
    color: #999;
    font-size: 12px;
    margin-bottom: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .item_price {
    color: red;
    font-size: 12px;
  }
}
</style>